    <template>
    <div id="dataBaseTablesInfo">
        <el-table
            ref="singleTable"
            :data="tableData"
            border
            highlight-current-row
            :header-cell-style="{background:'#eef1f6',color:'#606266',fontSize: '14px'}"
            :row-style="{height: '35px',border: 'none',}"
            :cell-style="{padding: '0'}"
            @current-change="handleCurrentChange"
            height="420px"
            v-loading="isShowLoading" element-loading-text="加载中"
            style="width: 100%;font-size: 10px">
            <el-table-column
                header-align="center"
                type="index"
                width="50">
            </el-table-column>
            <el-table-column
                header-align="center"
                prop="COMMENTS"
                label="中文名">
            </el-table-column>
            <el-table-column
                header-align="center"
                prop="TABLE_NAME"
                label="英文名">
            </el-table-column>
        </el-table>
        <!-- 分页组件 -->
        <div class="block" style="margin-left: 250px">
            <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentRowChange"
                :current-page="currentRow"
                :page-sizes="[50, 100, 200]"
                :page-size="currentPageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="tableData.recordNumber">
            </el-pagination>
        </div>
    </div>
</template>

<script>
    import {
        QUERY_DBLINK_ALL_TABLE
    } from '@api/url'
    import ajax from '@api/ajax'
    export default {
        name: 'DataBaseTablesInfo',
        data () {
            return {
                tableData: [],
                currentRow: 1,
                isShowLoading: false,
                tableDataListTmp: [],
                currentPageSize: 50
            }
        },
        props: {
            tableData1: [],
            type: Array
        },
        methods: {
            setCurrent (row) {
                this.$refs.singleTable.setCurrentRow(row)
            },
            handleSizeChange (val) {
                this.currentPageSize = val
                this.currentRow = 1
                this.handleCurrentRowChange(this.currentRow)
            },
            handleCurrentChange (val) {
                this.currentRow = val
            },
            handleCurrentRowChange (val, content) {
                debugger
                this.currentRow = val
                this.isShowLoading = true
                this.search['pageSize'] = this.currentPageSize
                this.search['pageNo'] = this.currentRow
                if (content) {
                    this.search['tableName'] = content.tableName
                }
                ajax.post(QUERY_DBLINK_ALL_TABLE, this.search).then(res => {
                    debugger
                    this.tableData = res.data.records
                    this.tableData['recordNumber'] = res.data.recordNumber
                    this.tableDataListTmp = this.tableData
                }).catch(err => {
                    console.error('错误！', err)
                }).finally(() => {
                    this.isShowLoading = false
                })
            },
            queryByCondition (searchFormData) {
                console.info(searchFormData)
                this.search = {
                    ...searchFormData
                }
                this.currentRow = 1
                this.search['pageSize'] = this.currentPageSize
                this.search['pageNo'] = 1
                this.getTablesList()
            },
            // 表格查询
            getTablesList () {
                this.isShowLoading = true
                console.info(this.search)
                this.handleCurrentRowChange(1)
            },
            // 搜索栏
            searchTableList (tableName) {
                // this.isShowLoading = true;
                // this.tableData = this.tableDataListTmp;
                // debugger
                // var tableDataTmp = []
                // for(let i in this.tableData){
                //     if(this.tableData[i]['TABLE_NAME'].indexOf(tableName) != -1 || this.tableData[i]['COMMENTS'].indexOf(tableName) !=-1) {
                //         tableDataTmp.push(this.tableData[i]);
                //         this.tableData = tableDataTmp;
                //     }
                //     this.isShowLoading = false;
                // }
                // this.tableData = tableDataTmp;
                //
                // this.isShowLoading = false;
            }
        }
    }
</script>
